package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import util.ConnectionUtil;

public class MajorDao {
	
	public static int getMajor(Object majorName) {

		Connection conn = ConnectionUtil.getConnection();
		 String sql = "SELECT majorid FROM major WHERE majorname LIKE '%"+majorName+"%';";
	     Statement stat;
	        try {
	        	stat = conn.createStatement();
	        	ResultSet rs = stat.executeQuery(sql);
	        	if(rs.next()) {
	        		int majorid = rs.getInt("majorid");
	        		return majorid;
	        		}
	        	}catch(Exception e) {
	        		e.printStackTrace();
	        	}
		return 0;
	}
}
